<? error_reporting(0);

if($_POST['action'] = 'widget')
{
    $response['success'] = false;
    if(file_exists("upload/a.csv"))
    {
        if (($gestor = fopen("upload/a.csv", "r")) !== FALSE) 
        {
            while (($datos = fgetcsv($gestor, 1000, ",")) !== FALSE) 
            {
                $numero = count($datos);
                $fila++;
                for ($c=0; $c < $numero; $c++) {
                    $datosArr[$fila][$c] = $datos[$c];
                }
            }
            fclose($gestor);
        }

        foreach($datosArr as $fila => $value)
        {
            $str.= "<span class='widget-a'><strong>".$value[1]."</strong> ".$value[2]." ".$value[3]."</span>";
        }
        
    }
    
    if(file_exists("upload/b.csv"))
    {
        if (($gestorB = fopen("upload/b.csv", "r")) !== FALSE) 
        {
            while (($datosB = fgetcsv($gestorB, 1000, ",")) !== FALSE) 
            {
                $numeroB = count($datosB);
                $filaB++;
                for ($cB=0; $cB < $numeroB; $cB++) {
                    $datosArrB[$filaB][$cB] = $datosB[$cB];
                }
            }
            fclose($gestorB);
        }

        foreach($datosArrB as $filaB => $valueB)
        {
            $str.= "<span class='widget-b'><strong>".$valueB[0]."</strong> ".$valueB[1]."</span>";
        }
        
    }
    
    $response['success']= true;
    $response['text']   = $str;
    
    echo json_encode($response);
    exit();
}
?>
